import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SSuitSkillInfo } from "../../../../../Message/Game/SSuitSkillInfo";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
//class SuitSkillInfoUpdateCommand
    
    export  class SuitSkillInfoUpdateCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            super.call(arg1);
            var loc1=arg1.messageBase as SSuitSkillInfo;
            _cache.role.suitSkillInfo = loc1;
            NetDispatcher.dispatchCmd(ServerCommand.SuitSkillInfoCommand, loc1);
            return;
        }

        /* internal  */runTimer(): void
        {
            if (SuitSkillInfoUpdateCommand.timer == null) 
            {
                SuitSkillInfoUpdateCommand.timer = new SecTimer();
            }
            SuitSkillInfoUpdateCommand.timer.addListener(TimerType.ENTERFRAME, this.updateRemainTimeHandler);
            SuitSkillInfoUpdateCommand.timer.addListener(TimerType.COMPLETE, this.secTimeCompleteHandler);
            SuitSkillInfoUpdateCommand.timer.reset();
            SuitSkillInfoUpdateCommand.timer.start();
            return;
        }

        /* internal  */updateRemainTimeHandler(arg1: SecTimer): void
        {
            var loc1;
            var loc2=((loc1 = _cache.role.suitSkillInfo).leftCdTime - 1);
            loc1.leftCdTime = loc2;
            return;
        }

        /* internal  */secTimeCompleteHandler(arg1: SecTimer): void
        {
            _cache.role.suitSkillInfo.leftCdTime = 0;
            arg1.stop();
            return;
        }

        private static /* var */timer: SecTimer;
    }
